package com.jcark.ui.utils;

import android.annotation.TargetApi;
import android.graphics.Outline;
import android.graphics.Rect;
import android.os.Build;
import android.view.View;
import android.view.ViewOutlineProvider;

/**
 * Description:圆角 <br>
 *
 * @author King.Zi<br>
 * @date 2023/4/28<br>
 * Email: 78688689@qq.com
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class RoundCornerProvider extends ViewOutlineProvider {
    /**
     * 圆角弧度
     */
    private final float mRadius;

    public RoundCornerProvider(float radius) {
        this.mRadius = radius;
    }

    @Override
    public void getOutline(View view, Outline outline) {
        Rect selfRect = new Rect(0, 0, view.getWidth(), view.getHeight());
        outline.setRoundRect(selfRect, mRadius);
    }
}